#ifndef LOG_SWITCH_2010_02_03
#define LOG_SWITCH_2010_02_03

#ifndef RECORD_LOG
#define _LOG4CPLUS_LOGGING_MACROS_HEADER_
#define LOG4CPLUS_TRACE(a,b)
#define LOG4CPLUS_DEBUG(a,b)
#define LOG4CPLUS_INFO(a,b)
#define LOG4CPLUS_WARN(a,b)
#define LOG4CPLUS_ERROR(a,b)
#define LOG4CPLUS_FATAL(a,b)

#define LOG4CPLUS_INIT(param)
#define LOG4CPLUS_DECLARE(logger)
#define LOG4CPLUS_IMPLEMENT(logger, name)
#define LOG4CPLUS_CLASS_DECLARE(logger)
#define LOG4CPLUS_CLASS_IMPLEMENT(classname, logger, name)

#define LOG4CPLUS_THIS_TRACE(a,b)
#define LOG4CPLUS_THIS_DEBUG(a,b)
#define LOG4CPLUS_THIS_INFO(a,b)
#define LOG4CPLUS_THIS_WARN(a,b)
#define LOG4CPLUS_THIS_ERROR(a,b)
#define LOG4CPLUS_THIS_FATAL(a,b)

#define LOG_CLASS_DECLARE()			
#define LOG_CLASS_IMPLEMENT(class_name, class_name_string) 

#define	LOG_TRACE( x )			
#define	LOG_DEBUG( x )			
#define	LOG_INFO( x )			
#define	LOG_WARN( x )		
#define	LOG_ERROR( x )			
#define LOG_FATAL( x )			

#define	LOG_THIS_TRACE( x )		
#define	LOG_THIS_DEBUG( x )		
#define	LOG_THIS_INFO( x )		
#define	LOG_THIS_WARN( x )		
#define	LOG_THIS_ERROR( x )		
#define LOG_THIS_FATAL( x )		


#else // !defined(RECORD_LOG)

#ifndef PRODUCT_LOG
#else
#define LOG4CPLUS_DISABLE_DEBUG
#define LOG4CPLUS_DISABLE_TRACE
#endif


#include <log4cplus/logger.h>
#include <log4cplus/loggingmacros.h>
#include <log4cplus/configurator.h>
#include <log4cplus/fileappender.h>
#include <log4cplus/layout.h>


#define LOG4CPLUS_INIT(param)	\
	log4cplus::SharedAppenderPtr _append(new log4cplus::FileAppender(param));\
	_append->setName(param" log");

#define LOG4CPLUS_DECLARE(logger)			extern log4cplus::Logger logger;
#define LOG4CPLUS_IMPLEMENT(logger, name)	log4cplus::Logger logger = log4cplus::Logger::getInstance(name);\
	logger.addAppender(_append);\
	std::string pattern = "%D [%t] %-5p %20c - %m%n" ;\
	std::auto_ptr<log4cplus::Layout> _layout(new log4cplus::PatternLayout(pattern));\
	_append->setLayout( _layout );\
	logger.setLogLevel(log4cplus::ALL_LOG_LEVEL);
#define LOG4CPLUS_CLASS_DECLARE(logger)						static log4cplus::Logger logger;
#define LOG4CPLUS_CLASS_IMPLEMENT(classname, logger, name)	log4cplus::Logger classname::logger = log4cplus::Logger::getInstance(name);

#define LOG4CPLUS_THIS_TRACE(a,b)	LOG4CPLUS_TRACE(a, "[GN] " << b )
#define LOG4CPLUS_THIS_DEBUG(a,b)	LOG4CPLUS_DEBUG(a, "[GN] " << b )
#define LOG4CPLUS_THIS_INFO(a,b)	LOG4CPLUS_INFO(a, "[GN] " << b )
#define LOG4CPLUS_THIS_WARN(a,b)	LOG4CPLUS_WARN(a, "[GN] " << b )
#define LOG4CPLUS_THIS_ERROR(a,b)	LOG4CPLUS_ERROR(a, "[GN] " << b )
#define LOG4CPLUS_THIS_FATAL(a,b)	LOG4CPLUS_FATAL(a, "[GN] " << b )

//////////////////////////////////////////////
#define LOG_CLASS_DECLARE()			LOG4CPLUS_CLASS_DECLARE( _logger )
#define LOG_CLASS_IMPLEMENT(class_name, class_name_string) LOG4CPLUS_CLASS_IMPLEMENT( class_name, _logger, class_name_string )

#define	LOG_TRACE( x )			LOG4CPLUS_TRACE( _logger, "[GN] " << x )
#define	LOG_DEBUG( x )			LOG4CPLUS_DEBUG( _logger, "[GN] " << x )
#define	LOG_INFO( x )			LOG4CPLUS_INFO( _logger, "[GN] " << x )
#define	LOG_WARN( x )			LOG4CPLUS_WARN( _logger, "[GN] " << x )
#define	LOG_ERROR( x )			LOG4CPLUS_ERROR( _logger, "[GN] " << x )
#define LOG_FATAL( x )			LOG4CPLUS_FATAL( _logger, "[GN] " << x )

#define	LOG_THIS_TRACE( x )		LOG4CPLUS_TRACE( _logger, "[GN] " << x )
#define	LOG_THIS_DEBUG( x )		LOG4CPLUS_DEBUG( _logger, "[GN] " << x )
#define	LOG_THIS_INFO( x )		LOG4CPLUS_INFO( _logger, "[GN] " << x )
#define	LOG_THIS_WARN( x )		LOG4CPLUS_WARN( _logger, "[GN] " << x )
#define	LOG_THIS_ERROR( x )		LOG4CPLUS_ERROR( _logger, "[GN] " << x )
#define LOG_THIS_FATAL( x )		LOG4CPLUS_FATAL( _logger, "[GN] " << x )
//////////////////////////////////////////////

#endif // RECORD_LOG
#endif // _THUNDER_LOG_SWITCH_
